package com.gxar.quick.ar.server.base.common.enums;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author linsy
 * @version 1.0
 * @created 2024/1/8 09:45
 */
public enum WorkTransferMethodEnum {

    MANUAL(0, "手动领取"),
    AUTOMATIC(1, "自动赠送");

    private final Integer code;
    private final String name;

    /**
     * 根据code获取
     *
     * @param code code
     * @return 响应
     */
    public static WorkTransferMethodEnum getByCode(Integer code) {
        WorkTransferMethodEnum workTransferMethodEnum = Arrays.stream(WorkTransferMethodEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(null);
        if (Objects.nonNull(workTransferMethodEnum)) {
            return workTransferMethodEnum;
        }
        return null;
    }

    WorkTransferMethodEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }
}
